#include<stdio.h>

int main(void)
{
    char s1[100];
    char s2[100];

    while (scanf("%s",s1) && scanf("%s",s2) != EOF)
    {
        int i,k,o;
        for (i = 0; i < 100; i++)
	    {
		    if (s1[i] == '\0')
		    {
			    break;
		    }	
	    }
        for (k = 0; k < 100; k++)
	    {
		    if (s2[k] == '\0')
		    {
			    break;
		    }	
	    }
        int boo = 1;
        int boo1 = 0;
        int l,l1 = 0;
        for (int j = 0; j < i; j++)
        {
    
                printf("%c",s1[j]);
                if (s2[0] == s1[j] || boo1)
            {
                if (!boo1)
                {
                    l = j;
                    o = i;
                    i = j + k;
                }
                
                boo1 = 1;
                if (s2[j-l]!=s1[j])
                {
                    boo1 = 0;
                    i = o;
                    j = l;
                }
            }
        }
        if (!boo1)
        {
            printf("\n0\n");
        }
        else printf("\n%d\n",l+1);
    }
    
}